package com.harlaus.lucenedemo.config;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.solr.core.SolrOperations;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;

@Configuration
@EnableSolrRepositories(basePackages = "com.harlaus.lucenedemo.mapper")
@EntityScan(basePackages = "com.harlaus.lucenedemo.entity")
public class SolrConfig {

    private String solrHost = "http://175.178.221.206:8900/solr/core1";

    @Bean
    public SolrClient solrClient(){
        return new HttpSolrClient.Builder(solrHost).build();
    }

    @Bean
    public SolrOperations solrOperations(){
        return new SolrTemplate(solrClient());
    }
}
